﻿using M.Warehouse.API.Application.Command.InventoryCommand;
using M.Warehouse.Repository.WarehouseInterface;
using MediatR;

namespace M.Warehouse.API.Application.CommandHandlers.InventoryHandlers
{
    public class InventoryCreateCommandHandlers : IRequestHandler<InventoryCreateCommand, int>
    {
        private readonly IInventoryRepository _inventoryRepository;
        public InventoryCreateCommandHandlers(IInventoryRepository inventoryRepository)
        {
            _inventoryRepository = inventoryRepository;
        }
        /// <summary>
        /// 添加库存(入/出/转库)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<int> Handle(InventoryCreateCommand request, CancellationToken cancellationToken)
        {
            return await _inventoryRepository.AddAsync(request);
        }
    }
}
